/**
 * describe:
 *
 * @author chaP
 * @date 2019/04/03
 */
package CodingTest.AC20190403;

import java.util.Arrays;
import java.util.Scanner;

public class Main1 {
    public int Main(int n,int[] arr){
        if(n ==2) return 0;
        Arrays.sort(arr);
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for(int i = n/2-1;i>=0;i--){
            max = Math.max(max,arr[i]+arr[n-1-i]);
            min = Math.min(min,arr[i]+arr[n-1-i]);
        }
        return max-min;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0;i<n;i++){
            arr[i] = sc.nextInt();
        }
        Main1 m = new Main1();
        System.out.println(m.Main(n,arr));
    }
}
